package Vistas;

import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Modelos.Ingrediente;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class FrmIngredientes extends javax.swing.JFrame {
	private JButton BtnNuevo;
	private JButton BtnGuardar;
	private JLabel LblCodigo;
	private JTextField TxtCodigo;
	private JLabel LblNombre;
	private JLabel LblStock;
	private JTextField TxtExistencia;
	private JLabel lblagregaringrediente;
	private JTextField TxtNombre;
	private JButton BtnSalir;
	private JButton BtnCancelar;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	
	public FrmIngredientes() {
		super();
		initGUI();
	}
	
	
	
	public JTextField getTxtCodigo() {
		return TxtCodigo;
	}

	public void Limpiar(){
	  HabilitarTextos(false);
	  TxtCodigo.setText("");
	  TxtExistencia.setText("");
	  TxtNombre.setText("");
	}
	
	
	
	public JTextField getTxtExistencia() {
		return TxtExistencia;
	}

	public Ingrediente MyIngrediente(){
		Ingrediente ingrediente = new Ingrediente(Integer.valueOf(TxtCodigo.getText()),TxtNombre.getText(),Double.valueOf(TxtExistencia.getText()));
		return ingrediente;
	}
	
	public void AsigMayor(int n){
		TxtCodigo.setText(String.valueOf(n+1));
		TxtCodigo.setEnabled(false);
		TxtExistencia.setEnabled(true);
		TxtNombre.setEnabled(true);
	}
	
	public void addListener(ActionListener actionListener) {
		BtnGuardar.addActionListener(actionListener);
		BtnNuevo.addActionListener(actionListener);	
		
		BtnSalir.addActionListener(actionListener);
		BtnCancelar.addActionListener(actionListener);
	}
	
	public void HabilitarTextos(Boolean e){
		TxtCodigo.setEnabled(e);
		TxtExistencia.setEnabled(e);
		TxtNombre.setEnabled(e);
	}

	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				BtnNuevo = new JButton();
				getContentPane().add(BtnNuevo);
				BtnNuevo.setText("Nuevo");
				BtnNuevo.setBounds(46, 209, 94, 22);
			}
		
			{
				BtnGuardar = new JButton();
				getContentPane().add(BtnGuardar);
				BtnGuardar.setText("Guardar");
				BtnGuardar.setBounds(140, 209, 103, 22);
			}
			{
				BtnCancelar = new JButton();
				getContentPane().add(BtnCancelar);
				BtnCancelar.setText("Cancelar");
				BtnCancelar.setBounds(243, 209, 89, 22);
			}
			{
				BtnSalir = new JButton();
				getContentPane().add(BtnSalir);
				BtnSalir.setText("Salir");
				BtnSalir.setBounds(331, 209, 86, 22);
			}
			{
				LblCodigo = new JLabel();
				getContentPane().add(LblCodigo);
				LblCodigo.setText("Codigo");
				LblCodigo.setBounds(60, 56, 72, 16);
			}
			{
				TxtCodigo = new JTextField();
				getContentPane().add(TxtCodigo);
				TxtCodigo.setBounds(132, 53, 121, 22);
				TxtCodigo.setEnabled(false);
			}
			{
				LblNombre = new JLabel();
				getContentPane().add(LblNombre);
				LblNombre.setText("Nombre");
				LblNombre.setBounds(60, 106, 74, 16);
			}
			{
				TxtNombre = new JTextField();
				getContentPane().add(TxtNombre);
				TxtNombre.setBounds(132, 103, 122, 22);
				TxtNombre.setEnabled(false);
			}
			{
				LblStock = new JLabel();
				getContentPane().add(LblStock);
				LblStock.setText("Existencia");
				LblStock.setBounds(60, 149, 63, 16);
			}
			{
				TxtExistencia = new JTextField();
				getContentPane().add(TxtExistencia);
				getContentPane().add(getLblagregaringrediente());
				TxtExistencia.setBounds(132, 146, 124, 22);
				TxtExistencia.setEnabled(false);
			}
			pack();
			this.setSize(466, 292);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private JLabel getLblagregaringrediente() {
		if(lblagregaringrediente == null) {
			lblagregaringrediente = new JLabel();
			lblagregaringrediente.setText("Agregar Ingrediente");
			lblagregaringrediente.setBounds(152, 12, 161, 21);
			lblagregaringrediente.setFont(new java.awt.Font("Segoe UI",1,16));
		}
		return lblagregaringrediente;
	}

}
